$(function() {
//观影方向类似的效果	
	$('.ttuorul').each(function(){
		var $this=$(this);
		$this.find(".ttuor").eq(0).find(".res_watch").show();
		$this.find(".ttuor").eq(0).find(".res_xs").hide();
		$this.find(".ttuor").bind("mouseover", function() {
			$this.find(".ttuor .res_watch").hide();
			$this.find(".ttuor .res_xs").show();
			$(this).find(".res_watch").show();
			$(this).find(".res_xs").hide();
		})
	})
	


});
(function($) {
function ShowImages() {}
	ShowImages.target = ".show-images";
	ShowImages.$target = $(ShowImages.target);
	ShowImages.$list = ShowImages.$target.find(".con");
	ShowImages.$items = ShowImages.$target.find("ul");
	ShowImages.$btn = ShowImages.$target.find(".changing-over");
	
	ShowImages.now = 0;  //起始索引.
	ShowImages.num = 1;  //展示数量.
	ShowImages.itemWidth = ShowImages.$items.width();  //项目宽度.
	ShowImages.itemlength = ShowImages.$items.length;  //项目长度.
	ShowImages.maxScroll = ShowImages.itemlength - ShowImages.num;  //最大滚动.
	
		function ShowImages() {}
	ShowImages.target = ".details-img";
	ShowImages.$target = $(ShowImages.target);
	ShowImages.$list = ShowImages.$target.find(".con");
	ShowImages.$items = ShowImages.$target.find("ul");
	ShowImages.$btn = ShowImages.$target.find(".changing-over");

	ShowImages.now = 0; //起始索引.
	ShowImages.num = 1; //展示数量.
	ShowImages.itemWidth = ShowImages.$items.width(); //项目宽度.
	ShowImages.itemlength = ShowImages.$items.length; //项目长度.
	ShowImages.maxScroll = ShowImages.itemlength - ShowImages.num; //最大滚动.

	/**
	 * 初始化程序.
	 * @return {Object} this.
	 */
	ShowImages.init = function() {
		if($(".con ul").length<2) {
				$(".right").hide();
				$(".left").hide();
				
		}
		ShowImages.$btn.on("click", function() {
			
			var _$parent = $(this).parent(),
				_now = _$parent.data("now") || ShowImages.now,
				_itemWidth = ShowImages.itemWidth,
				_maxScroll = _$parent.data("maxScroll", _$parent.find("ul").length - ShowImages.num ).data("maxScroll");
			
			if( ShowImages.$list.filter(":animated").length ) {  //在进行动画时屏蔽单击操作.
				return ;
			}
			
			
			if($(this).hasClass("left")){
				$(".right").removeClass("gray");
				if(_now<=1){
					_now=0;
					$(".left").addClass("gray");
				}
				else{
					_now--;

				}
			}
			else{
				$(".left").removeClass("gray");
				if(_now>=_maxScroll-1){
					_now=_maxScroll;
					$(".right").addClass("gray");
				}
				else{
					_now++;

				}
			}
			_$parent.data("now",_now);
			
			_$parent.find(".con").animate({"margin-left": -_now * _itemWidth}, "fast");
			
		});
		
		// return ShowImages.$target.map(function() {
		// 	$(this).find("ul").length > ShowImages.num
		// 		&& $(this).find(".changing-over.right").show();
		// });
	}
	
	ShowImages.init();

	/*自适应屏幕宽度*/
	function winResize() {
		var winWidth = $(window).width();
		if (winWidth < 1200) {
			$("body").addClass("w980");
		} else {
			$("body").removeClass();
		}
//		sWidth = $(".pichow").width();
//		$(".pichow ul").css("width", sWidth * (len));
//		showPics(i_bnr);
//
//		ShowImages.$list.css("margin-left", "0");
//		ShowImages.itemWidth = ShowImages.$items.width();
//		ShowImages.init();
		ShowImages.itemWidth = ShowImages.$items.width(); //项目宽度.
		var _itemWidth = ShowImages.itemWidth;
		var _now = $("#currentLi").parent("ul").index();
		$("#ullist").animate({"margin-left": -_now * _itemWidth}, 0);
		$(".left").parent().data("now",_now);
		if(_now>0){
			$(".left").removeClass("gray");
			if(_now==ShowImages.maxScroll){$(".right").addClass("gray");}
		}
	};

	/*调用*/
	winResize();
	$(window).resize(function() {
		winResize();
	});
})(jQuery);

//选项卡 -  n变量    
//function setTab1(name, cursel, n) {
//	for (i = 1; i <= n; i++) {
//		var menu = document.getElementById(name + i);
//		var con = document.getElementById("j_" + name + "_" + i);
//		menu.toggleClass = i == cursel ? "hover" : "";
//		con.style.display = i == cursel ? "block" : "none";
//	}
//}
function setTab1(name, cursel, n) {
        var menu = $("#"+name + cursel);
        var thecon = $("#j_" + name + "_" + cursel);
        menu.addClass("hover").siblings("li").removeClass("hover");
        for(i = 1; i <= n; i++){
            $("#j_" + name + "_" + i).hide();
        }
        thecon.show();
    }

function hideTab(name,i,obj){
	obj.removeClass("hover");
	$("#j_" + name + "_" + i).hide();
}



//右下角的老版本一样 暂时不改
//function setTab(name, cursel, n) {
//	for (i = 1; i <= n; i++) {
//		var menu = document.getElementById(name + i);
//		var con = document.getElementById("jsweb8_" + name + "_" + i);
//		menu.toggleClass("hover"); //className
//		con.style.display = i == cursel ? "block" : "none";
//	}
//}


function setTab(name, cursel, n) {
        var menu = $("#"+name + cursel);
        var thecon = $("#jsweb8_" + name + "_" + cursel);
        menu.addClass("hover").siblings("li").removeClass("hover");
        for(i = 1; i <= n; i++){
            $("#jsweb8_" + name + "_" + i).hide();
        }
        thecon.show();
    }

function hideTab(name,i,obj){
	obj.removeClass("hover");
	$("#jsweb8_" + name + "_" + i).hide();
}







/*城市切换*/
var nowcity=$("#city .chs").text();
var cityList=$("#city .ctype a");
for(var i=0;i<cityList.length;i++){
	if(cityList.eq(i).text()==nowcity){
		$("#city .ctype a").eq(i).addClass("now");
		break;
	}
}

//描点连接
 function goTo(obj) {
  			var scrollTop = $(this).scrollTop();//触发点击事件的
     		 var tabTop = $(obj).offset().top;//跳转到某个div的
     		 window.scrollTo(0,tabTop);
  		}




